[Coding039] LeetCode 203

Remove Linked List Elements

Ben 2024.04.09

 

More coding records

Get the knowledge flowing and circulating! :)

目录

本题收获

题目:203. Remove Linked List Elements

Given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head.

Example 1:

img

Example 2:

Example 3:

Constraints:


代码1

代码解读 | 评价

这个代码显然太复杂了!

复杂度分析

image-20240406224822030


代码2

image-20240406224729030

代码3(配 · 手绘过程图)

image-20240409110304249

image-20240409110321116

复杂度分析

image-20240409105445189

代码4

测试样例